package net.lab1024.smartadmin.module.business.easyComputeResult.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.lab1024.smartadmin.common.domain.PageResultDTO;
import net.lab1024.smartadmin.common.domain.ResponseDTO;
import net.lab1024.smartadmin.module.business.easyComputeResult.dao.EasyComputeResultDao;
import net.lab1024.smartadmin.module.business.easyComputeResult.domain.dto.EasyComputeResultAddDTO;
import net.lab1024.smartadmin.module.business.easyComputeResult.domain.dto.EasyComputeResultQueryDTO;
import net.lab1024.smartadmin.module.business.easyComputeResult.domain.dto.EasyComputeResultUpdateDTO;
import net.lab1024.smartadmin.module.business.easyComputeResult.domain.entity.EasyComputeResultEntity;
import net.lab1024.smartadmin.module.business.easyComputeResult.domain.vo.EasyComputeResultExcelVO;
import net.lab1024.smartadmin.module.business.easyComputeResult.domain.vo.EasyComputeResultVO;
import net.lab1024.smartadmin.util.SmartBeanUtil;
import net.lab1024.smartadmin.util.SmartPageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * [  ]
 *
 * @author �Ζ�
 * @version 1.0
 * @company ��������
 * @copyright (c)  ��������Inc. All rights reserved.
 * @date 2022-06-08 16:08:00
 * @since JDK1.8
 */
@Service
public class EasyComputeResultService {

    @Autowired
    private EasyComputeResultDao easyComputeResultDao;

    /**
     * ����id��ѯ
     */
    public EasyComputeResultEntity getById(Long id){
        return  easyComputeResultDao.selectById(id);
    }

    /**
     * ��ҳ��ѯ
     * @author �Ζ�
     * @date 2022-06-08 16:08:00
     */
    public ResponseDTO<PageResultDTO<EasyComputeResultVO>> queryByPage(EasyComputeResultQueryDTO queryDTO) {
        Page page = SmartPageUtil.convert2QueryPage(queryDTO);
        IPage<EasyComputeResultVO> voList = easyComputeResultDao.queryByPage(page, queryDTO);
        PageResultDTO<EasyComputeResultVO> pageResultDTO = SmartPageUtil.convert2PageResult(voList);
        return ResponseDTO.succData(pageResultDTO);
    }

    /**
     * ���
     * @author �Ζ�
     * @date 2022-06-08 16:08:00
     */
    public ResponseDTO<String> add(EasyComputeResultAddDTO addDTO) {
        EasyComputeResultEntity entity = SmartBeanUtil.copy(addDTO, EasyComputeResultEntity.class);
        easyComputeResultDao.insert(entity);
        return ResponseDTO.succ();
    }

    /**
     * ���
     * @author �Ζ�
     * @date 2022-06-08 16:08:00
     */
    public ResponseDTO<String> add(EasyComputeResultEntity entity) {

        easyComputeResultDao.insert(entity);
        return ResponseDTO.succ();
    }

    /**
     * �༭
     * @author �Ζ�
     * @date 2022-06-08 16:08:00
     */
    @Transactional(rollbackFor = Exception.class)
    public ResponseDTO<String> update(EasyComputeResultUpdateDTO updateDTO) {
        EasyComputeResultEntity entity = SmartBeanUtil.copy(updateDTO, EasyComputeResultEntity.class);
        easyComputeResultDao.updateById(entity);
        return ResponseDTO.succ();
    }

    /**
     * ɾ��
     * @author �Ζ�
     * @date 2022-06-08 16:08:00
     */
    @Transactional(rollbackFor = Exception.class)
    public ResponseDTO<String> deleteByIds(List<Long> idList) {
        easyComputeResultDao.deleteByIdList(idList);
        return ResponseDTO.succ();
    }

    /**
     * ��ѯȫ����������
     * @author �Ζ�
     * @date 2022-06-08 16:08:00
     */
    public List<EasyComputeResultExcelVO> queryAllExportData(EasyComputeResultQueryDTO queryDTO) {
        return easyComputeResultDao.queryAllExportData( queryDTO);
    }

    /**
     * ������ѯ��������
     * @author �Ζ�
     * @date 2022-06-08 16:08:00
     */
    public List<EasyComputeResultExcelVO> queryBatchExportData(List<Long> idList) {
        return easyComputeResultDao.queryBatchExportData(idList);
    }
}
